<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>Hello MUI</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<style>
			h5 {
				margin: 5px 7px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">玩家上下分</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded" style="margin: 5px;">
				<!--<h5>默认搜索框：</h5>
				<div class="mui-input-row mui-search">
					<input type="search" class="mui-input-clear" placeholder="">
				</div>-->
				<!--<h5 class="mui-plus-visible">语音输入搜索框：</h5>
				<div class="mui-input-row mui-search mui-plus-visible">
					<input id="search" type="search" class="mui-input-speech mui-input-clear" placeholder="带语音输入的搜索框">
				</div>-->
				<!--<h5>密码框：</h5>
				<div class="mui-input-row mui-password">
					<input type="password" class="mui-input-password">
				</div>-->
				<form class="mui-input-group">

					<div class="mui-input-row">
						<label>目标玩家</label>
						<input id="username" type="text" class="mui-input-clear" placeholder="玩家账号">
					</div>
					<div class="mui-input-row">
						<label>上下分值</label>
						<input id="gold" type="number" class="mui-input-clear" placeholder="负分则是为玩家下分">
					</div>

					<div class="mui-button-row">
						<button id="btn_confrim" type="button" class="mui-btn mui-btn-primary">确认</button>&nbsp;&nbsp;
						<button type="button" class="mui-btn mui-btn-danger" onclick="return false;">取消</button>
					</div>
				</form>
				<div class="mui-input-row" style="margin: 10px 5px;">
					<textarea id="textarea" rows="5" placeholder="返回结果" disabled=""></textarea>
				</div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/utils/httpUtils.js"></script>
		<script>
			mui.init({
				swipeBack: true //启用右滑关闭功能
			});
			//语音识别完成事件
			mui.ready(function() {
				var http_utils = new HttpUtils(mui.os.plus);
				var url = "wxhh/add_gold_for_user"
				var username = document.getElementById("username");
				var gold = document.getElementById("gold");
				var btn_confirm = document.getElementById("btn_confrim");
				var result_show = document.getElementById("textarea");

				var success_call_bk = function(data) {
					var code = data.code;
					result_show.innerHTML = data.desc;
				}

				var error_call_bk = function(data) {
					for(i in data){
						console.log(i);
					}
					var code = data.status;
					result_show.innerHTML = data.desc;
				}

				btn_confirm.addEventListener("tap", function(event) {
					console.log("用户名:"+username.value);
					console.log("gole="+gold.value);
					params = {
						tel: username.value,
						gold: gold.value
					}
					if(username.value == "") {
						mui.toast("请输入用户名");
						return
					}

					if(gold.value > 1000000) {
						mui.toast("每次最多上分不能超过1千万！");
						gold.value = "";
						return
					}

					http_utils.post(url, params, success_call_bk, error_call_bk);
				});
			});
		</script>
	</body>

</html>